<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Admin
{
    use SoftDeletes;
    use HasFactory;

    protected $table = 'zfm_Administrator';

    /**
     * ’展示信息
     * @return mixed
     */
    public static function show()
    {
        return self::paginate(10);
    }

    /**
     * 删除数据
     * @param $id
     * @return int
     */
    public static function del($id, $idDate)
    {
        return self::where([$id => $idDate])->delete();
    }


    /**
     * 搜索方法
     * @param $data
     */
    public static function search($username, $where)
    {
        return self::where($username, 'like', "$where")->get(['name', 'phone', 'firm', 'created_at']);
    }


    /**
     * 查找对应的id
     * @param $id
     * @return \Illuminate\Database\Eloquent\Builder|Model|object|null
     */
    public static function brokerId($id)
    {
        return self::query()->first();
    }

    /**
     *  修改
     * @param $name
     * @param $email
     * @param $password
     * @param $role_id
     * @return int
     */
    public static function updates($find)
    {
        return self::query()->update($find);
    }
}
